﻿CMAKE_MINIMUM_REQUIRED( VERSION 3.5 )

message("============ ${CURRENT_FOLDER}")
STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} )
message("name =" ${CURRENT_FOLDER})
project(${CURRENT_FOLDER}  VERSION 0.1 LANGUAGES CXX)
message("============ ${CURRENT_FOLDER}")

SET( QT_VERSION_MAJOR 6 )
SET( DEPLOY_QT_HOME "C:/Qt/6.4.2/msvc2019_64/" )
SET( Qt6_DIR "${DEPLOY_QT_HOME}/lib/cmake/Qt${QT_VERSION_MAJOR}" )
SET( Qt6CoreTools_DIR "${DEPLOY_QT_HOME}/lib/cmake/Qt${QT_VERSION_MAJOR}CoreTools")
SET( OpenCV_DIR "C:/libs/opencv/build/")
SET( Qt6GuiTools_DIR "${DEPLOY_QT_HOME}/lib/cmake/Qt${QT_VERSION_MAJOR}GuiTools" )

SET( CMAKE_C_STANDARD 99 )
SET( CMAKE_C_STANDARD_REQUIRED ON )
SET( CMAKE_C_VISIBILITY_PRESET hidden )

SET( CMAKE_CXX_STANDARD 17 )
SET( CMAKE_CXX_STANDARD_REQUIRED ON )
SET( CMAKE_CXX_VISIBILITY_PRESET hidden )

INCLUDE( GenerateExportHeader )
INCLUDE( GNUInstallDirs )


SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} )
SET( CMAKE_INSTALL_BINDIR ./)
SET( CMAKE_INSTALL_LIBDIR ./)
SET( CMAKE_INSTALL_PREFIX ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
SET( EXECUTABLE_OUTPUT_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
SET( RUNTIME_OUTPUT_DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY} )

SET( CMAKE_AUTOUIC ON )
SET( CMAKE_AUTOMOC ON )
SET( CMAKE_AUTORCC ON )

SET(user_install_last_dir ../bin)

function(get_current_path_dirs out_list check_path_dir)
	set(get_path_dir ${check_path_dir})
	set(for_each_list_dirs)
	if(IS_DIRECTORY ${get_path_dir} )
		FILE(GLOB child_dir RELATIVE ${get_path_dir} ${get_path_dir}/*)
		foreach(dir_path ${child_dir})
			set(current_path ${get_path_dir}/${dir_path})
			if(IS_DIRECTORY ${current_path})
				list(APPEND for_each_list_dirs ${current_path} )
			endif()
		endforeach()
		set(${out_list} ${for_each_list_dirs} PARENT_SCOPE)
	endif( )
endfunction()


set(sub_path_list)
get_current_path_dirs(out_path_list ${CMAKE_CURRENT_SOURCE_DIR}/src)
foreach(out_dir ${out_path_list})
	get_current_path_dirs(out_path_list2 ${out_dir})
	foreach(sub_out_dir ${out_path_list2})
		string(REPLACE ${CMAKE_SOURCE_DIR}/ "" out_path  ${sub_out_dir})
		message(STATUS "正在添加路径 :\t" ${out_path})
		ADD_SUBDIRECTORY( ${out_path} )
	endforeach()
endforeach()
